<?php
/**
 * 陈杰  18323491246
 */


namespace App\Http\Middleware;

use App\Models\Api\ExtendUserModel;
use Closure;
use App\Libraries\Send;
use App\Models\AdminUserTokenModel as AdminToken;
use App\Models\AdminUserModel as AdminUser;
use App\Exceptions\AdminException;
use App\Models\AdminRuleGroupModel;
use App\Models\AdminRulesModel;
use Illuminate\Support\Facades\DB;
use Qiniu\Http\Request;
use SebastianBergmann\Environment\Console;

class checkLogin
{
    use Send;
    #UF997097637021
    protected static $key = 'UF((&)(&^#&)@!';


    public function handle($request, Closure $next)
    {


        if ($request->has('count')) {
            $count = intval($request->input('count')) > 0 ? intval($request->input('count')) : 10;
        } else $count = 10;
        if ($request->has('page')) {
            $page = intval($request->input('page')) > 0 ? intval($request->input('page')) * $count : 0;
            $page = intval($request->input('page')) > 0 ? (int)$request->input('page') : 0;
        } else $page = 0;
        $user = ExtendUserModel::get_by_uid(1);
        $request->attributes->add(['uid' => 1, 'count' => $count, 'page' => $page, 'user' => $user]);
        return $next($request);
    }


}
